package com.springframework.boot.clients;


import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 调用服务的 openfeign  client
 */
@FeignClient(value = "commodities")//value对应的是consul中的应用服务的名称
public interface CommoditiesClient {

    @GetMapping("commodities/showMsg")
    String showMsg();

    /**
     * 根据商品id查询商品信息
     * @param commodityId  商品id
     * @return  商品信息
     */
    @GetMapping("commodities/commodityId")//注意：使用openfeign的get方式传递参数，参数变量必须@RequestParam注解进行修饰
    public Map<String,Object> findById(@RequestParam("commodityId") String commodityId);


    @PostMapping("commodities/saveCommodity")
    public Map<String,Object> saveCommodity(@RequestParam("commodityName") String commodityName);
}
